package gui;

/*
 * @Author: Andy Vidkjaer
 */	

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import domain.Service;

public class OpretBehandlingFrame extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private MainFrame from;
	/**
	 * Create the frame.
	 */
	public OpretBehandlingFrame(MainFrame from) {
		this.from = from;
		setTitle("Opret Behandling");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 354, 217);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		this.setLocationRelativeTo(null);
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		
		textField = new JTextField();
		textField.setUI(new HintTextField("Navn", false));
		textField.setColumns(10);
		panel.add(textField);
		
		JPanel panel_1 = new JPanel();
		contentPane.add(panel_1, BorderLayout.SOUTH);
		
		JButton button = new JButton("Ok");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Service.getInstance().createBehandling(textField.getText());
				OpretBehandlingFrame.this.from.updateBehandlingsTable();
			OpretBehandlingFrame.this.dispose();
			}
		});
		panel_1.add(button);
		
		JButton button_1 = new JButton("Annuller");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				OpretBehandlingFrame.this.dispose();
			}
		});
		panel_1.add(button_1);
		
		Component verticalStrut = Box.createVerticalStrut(45);
		contentPane.add(verticalStrut, BorderLayout.NORTH);
		this.setVisible(true);

	}

}
